<template>
  <el-form :model="form"  style="width: 600px">
    <el-form-item label="角色名称:">
      <el-input v-model="form.roleName" />
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">保存</el-button>
    </el-form-item>
  </el-form>
</template>
<script setup lang="ts">
import {ref,reactive,onMounted} from 'vue'
import axios from 'axios'
import { useRoute,useRouter } from 'vue-router';
import { ElMessage,ElMessageBox } from 'element-plus';
const route=useRoute();
const router=useRouter();
const form=reactive({
    roleName:'',
    createName:localStorage.getItem("userName"),
    createTime:new Date(),
    isDeleted:false
})

const onSubmit=()=>{
    axios.post("/api/Role/Create",form)
    .then(res=>{
        if(res.data.code==0){
            ElMessage.success("添加成功");
            router.push({
                name:'RoleList'
            })
        }
    })
    .catch(err=>{
        console.log(err);
    })
}

onMounted(()=>{

})
</script>